<template>
  <a-modal
    :visible="adviseVisible"
    :title="typeUser == 'dd'?'督导团对课程教学的意见和建议':'学生对课程教学的意见和建议'"
    :width="980"
    :confirmAdLoading="confirmAdLoading"
    @cancel="() => { $emit('cancelAd') }"
    okText="导出"
    @ok="onOk"
  >
    <a-row>
        <a-col :span="8">
            课程：{{courseInfo.kcmc}}
        </a-col>
    </a-row>
    <a-card :bordered="false" style="margin-top: 10px">
      <s-table
            ref="table"
            size="default"
            :columns="columns"
            :data="loadData"
            :alert="{ show: false }"
            :pageSize="10"
            bordered
            :scroll="{ y: 450 }"
        >
        <span slot="serial" slot-scope="text, record, index">
          {{ index + 1 + (parameter.pageNo - 1) * parameter.pageSize }}
        </span> 
        </s-table>
    </a-card>
    
  </a-modal>
</template>

<script>
import { STable } from '~'
export default {
    name: 'comTeachDetail',
    props: {
        adviseVisible: Boolean,
        typeUser: '',
        courseInfo: {
        type: Object,
        default () {
            return {}
        }
    },
    confirmAdLoading: Boolean
  },
  watch:{
      adviseVisible(value){
          if(value){
                this.$refs.table.refresh(true)
          }
      },
  },
   data(){
        return{
          queryParam: {},
            columns:[
                {
                  title: '序号',
                  width: '100px',
                  scopedSlots: { customRender: 'serial' }
                },
                {
                    title: '意见和建议',
                    dataIndex: 'pjnl',
                },
               
            ],
            parameter: {
                pageNo: 1,
                pageSize: 10
            },
            loadData: parameter => {
              this.parameter = parameter
              parameter.pageNum = parameter.pageNo
              // let params = Object.assign(this.queryParam, parameter)
              let url = ''
                if(this.typeUser == 'dd'){
                    url = this.$api.student.ddEduAdvise(this.courseInfo.pkxxId)
                }else{
                    url = this.$api.student.teaEduAdvise(this.courseInfo.pkxxId)
                }
              return url.then(res => {
                return {
                  data: res.data.rows,
                  pageNo: parameter.pageNum,
                  pageSize: parameter.pageSize,
                  totalPage: Math.ceil(res.data.total / parameter.pageSize),
                  totalCount: res.data.total
                }
              })
            },
                    
        }
    },
  components: {
    STable
  },
  methods: {
    onOk(){
        if(this.typeUser == 'dd'){
          this.$export('/teacherClient/kcpjzbDd/exportPjnl?pkxxId=' + this.courseInfo.pkxxId, {})
        }else{
          this.$export('/teacherClient/kcpjzbXs/exportPjnl?pkxxId=' + this.courseInfo.pkxxId, {})
          
        }
    }
  }
}
</script>

<style>

</style>
